﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Interactivity;
using NicoView.Speech;
using NicoView.ViewModel.Message;

namespace NicoView.View.Behaviors
{
    //
    // Action のターゲット要素をその親以外にしたい場合、クラスを
    // TriggerAction の代わりに TargetedTriggerAction から拡張します
    //
    public class SetAuthAction : ShowWindowAction<NicoViewUserAuthSetWindow>
    {
        public SetAuthAction()
        {

        }



        protected override void OnInvoke(object msg)
        {
            var message = (NicoViewSetAuthMessage)msg;
            this.Target.UserSetControl.WarnArea.Text = message.Content.EventDescription;
            this.Target.UserSetControl.MailText.Text = message.Content.BaseAuth.Mail;
            this.Target.UserSetControl.DataContext.OnSet += authArgs =>
            {
                message.Content.Set(authArgs.Auth);
            };
        }

        protected override void OnShow()
        {
            this.Target.ShowDialog();
        }
    }
}